<template>
  <div id="app">
    <router-view />
  </div>
</template>
<script>
import request from "@/untils/request";
import "@/api/routerList";
import Cs1 from "@/views/testRouter/cs1";
import Cs2 from "@/views/testRouter/cs2";
import Cs3 from "@/views/testRouter/cs3";
import Cs4 from "@/views/testRouter/cs4";
import Cs5 from "@/views/testRouter/cs5";
export default {
  created() {
    let obj = {
      path: "/cs1",
      component: Cs1,
    };
    console.log(obj, 1211111);
    request.get("/api/router").then((res) => {
      // console.log(res.data.list, 123);
      let arr = [];
      res.data.list &&
        res.data.list.forEach((item, index) => {
          let data = {};
          data = item;
          switch (index + 1) {
            case 1:
              data.component = Cs1;
              break;
            case 2:
              data.component = Cs2;
              break;
            case 3:
              data.component = Cs3;
              break;
            case 4:
              data.component = Cs4;
              break;
            case 5:
              data.component = Cs5;
              break;
          }
          arr.push(data, 123);
        });
      console.log(arr, 123);
      this.$router.addRoutes(arr);
    });
    router.removeRoute("")
  },
};
</script>

<style>
* {
  margin: 0px;
  padding: 0px;
  list-style: none;
}
</style>
